package com.mdmedia.cms.action;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.mdmedia.cms.common.assist.UtilPath;
import com.mdmedia.cms.entiy.base.User;
import com.mdmedia.cms.service.IBaseService;

@Controller
@RequestMapping("/user")
public class UserController implements UtilPath{
	
	@Autowired
	@Qualifier("serviceuser")
	private IBaseService<User> userService;

	@RequestMapping("/save")
	public ModelAndView save(@Valid User user, BindingResult result){
		
		if(result.hasErrors()) {  
			return new ModelAndView(path_user); 
        }
		//userService.createObject(user);
		List<User> users = userService.queryDataList("", null);
		
		
		return new ModelAndView(path_user+"/list");   
	}
	@SuppressWarnings("rawtypes")
	public IBaseService getUserService() {
		return userService;
	}
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void setUserService(IBaseService userService) {
		this.userService = userService;
	}
	
	
}
